home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / s-signal.adb < prev    next >
Text File  |  1996-01-30  |  22KB  |  640 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --                S Y S T E M . T A S K I N G . S I G N A L S               --
  6. --                                  B o d y                                 --
  7. --                                                                          --
  8. --                             $Revision: 1.11 $                             --
  9. --                                                                          --
  10. --       Copyright (c) 1991,1992,1993,1994, FSU, All Rights Reserved        --
  11. --                                                                          --
  12. -- GNARL is free software; you can redistribute it  and/or modify it  under --
  13. -- terms  of  the  GNU  Library General Public License  as published by the --
  14. -- Free Software  Foundation;  either version 2, or (at  your  option)  any --
  15. -- later  version.  GNARL is distributed  in the hope that  it will be use- --
  16. -- ful, but but WITHOUT ANY WARRANTY;  without even the implied warranty of --
  17. -- MERCHANTABILITY  or  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Gen- --
  18. -- eral Library Public License  for more details.  You should have received --
  19. -- a  copy of the GNU Library General Public License along with GNARL;  see --
  20. -- file COPYING.LIB.  If not,  write to the  Free Software Foundation,  675 --
  21. -- Mass Ave, Cambridge, MA 02139, USA.                                      --
  22. --                                                                          --
  23. ------------------------------------------------------------------------------
  24.  
  25. --  This package does not follow the GNARL/GNULL layering. It uses both GNARL
  26. --  and GNULL packages without a clear layer in between.
  27.  
  28. with System.Error_Reporting;
  29. with System.Storage_Elements;
  30. with System.Task_Primitives; use System.Task_Primitives;
  31. with System.Tasking.Utilities;
  32. with System.Tasking.Rendezvous;
  33. with Interfaces.C.POSIX_Error;
  34. with Interfaces.C.Pthreads;
  35.  
  36. package body System.Signals is
  37.  
  38.    package RTE renames Interfaces.c.POSIX_RTE;
  39.    package POSIX_Error renames Interfaces.C.POSIX_Error;
  40.  
  41.    Failure : Interfaces.C.POSIX_Error.Return_Code
  42.       renames Interfaces.C.POSIX_Error.Failure;
  43.  
  44.    Assertions_Checked : constant Boolean := True;
  45.  
  46.    Max_Signal : constant := 32;
  47.  
  48.    subtype Signal_Index is RTE.Signal range 1 .. Max_Signal - 1;
  49.  
  50.    type Signal_Assoc is record
  51.       T : Tasking.Task_ID;
  52.       E : Tasking.Task_Entry_Index;
  53.    end record;
  54.  
  55.    Null_Signal_Assoc : constant Signal_Assoc
  56.       := Signal_Assoc' (T => Tasking.Null_Task, E => Tasking.Null_Task_Entry);
  57.  
  58.    User_Handler_Table : array (Signal_Index) of Signal_Assoc
  59.      := (others => Null_Signal_Assoc);
  60.  
  61.    type Server_Info is record
  62.       Task_ID : Tasking.Task_ID;  --  Indivisual signal handling task's Task_ID
  63.       Blocked : boolean;          --  Process level Blocking Indication
  64.       Ignored : boolean;          --  Process level Ignoring Indication
  65.       Asynchronous : boolean;     --  Only Asynchronous signals can have
  66.    end record;                    --  user level handler
  67.  
  68.    Signal_Server_Table : array (Signal_Index) of Server_Info
  69.       := (RTE.SIGKILL | RTE.SIGSTOP | RTE.SIGALRM | RTE.SIGILL | RTE.SIGFPE |
  70.           RTE.SIGSEGV | RTE.SIGEMT  | RTE.SIGBUS | RTE.SIGTRAP |
  71.           RTE.SIGABRT | RTE.SIGUSR1
  72.       --  These two signals are asynchronous signals according to POSIX
  73.           => (Task_ID      => Tasking.Null_Task,
  74.               Blocked      => false,
  75.               Ignored      => false,
  76.               Asynchronous => false),
  77.           others
  78.           => (Task_ID      => Tasking.Null_Task,
  79.               Blocked      => false,
  80.               Ignored      => false,
  81.               Asynchronous => true));
  82.  
  83.    task type Handler_Task (S : RTE.Signal);
  84.  
  85.    --  T : Handler_Task (RTE.SIGABRT);
  86.    --  SIGABRT should also be available for interrupt entry.
  87.    T1  : Handler_Task (RTE.SIGHUP);
  88.    T2  : Handler_Task (RTE.SIGINT);
  89.    T3  : Handler_Task (RTE.SIGPIPE);
  90.    T4  : Handler_Task (RTE.SIGQUIT);
  91.    T5  : Handler_Task (RTE.SIGTERM);
  92.    --  T : Handler_Task (RTE.SIGUSR1);
  93.    --  SIGUSR1 should also be available for interrupt entry.
  94.    T6  : Handler_Task (RTE.SIGUSR2);
  95.    T7  : Handler_Task (RTE.SIGCHLD);
  96.    T8  : Handler_Task (RTE.SIGCONT);
  97.    T9  : Handler_Task (RTE.SIGTSTP);
  98.    T10 : Handler_Task (RTE.SIGTTIN);
  99.    T11 : Handler_Task (RTE.SIGTTOU);
  100.  
  101.    --  Additional asynchronous signals not required by POSIX
  102.    T12 : Handler_Task (RTE.SIGSYS);
  103.    T13 : Handler_Task (RTE.SIGURG);
  104.    T14 : Handler_Task (RTE.SIGIO);
  105.    T15 : Handler_Task (RTE.SIGXCPU);
  106.    T16 : Handler_Task (RTE.SIGXFSZ);
  107.    T17 : Handler_Task (RTE.SIGVTALRM);
  108.    T18 : Handler_Task (RTE.SIGPROF);
  109.    T19 : Handler_Task (RTE.SIGWINCH);
  110.    T20 : Handler_Task (RTE.SIGLOST);
  111.  
  112.    task Signal_Manager is
  113.       entry Bind_Handler (T : Tasking.Task_ID;
  114.                           E : Tasking.Task_Entry_Index;
  115.                           S : RTE.Signal);
  116.       entry Unbind_Handler (T : Tasking.Task_ID);
  117.       entry Block_Signal (S : RTE.Signal);
  118.       entry Unblock_Signal (S : RTE.Signal);
  119.    end Signal_Manager;
  120.  
  121.    M : array (Signal_Index) of Lock;
  122.  
  123.    C : array (Signal_Index) of Condition_Variable;
  124.  
  125.    procedure Assert (B : Boolean; M : String)
  126.      renames Error_Reporting.Assert;
  127.  
  128.    function Address_To_Pointer is new
  129.      Unchecked_Conversion (System.Address, RTE.sigaction_ptr);
  130.  
  131.    function Address_To_Signal (A : System.Address) return RTE.Signal;
  132.  
  133.    function Address_To_Signal (A : System.Address) return RTE.Signal is
  134.    begin
  135.       return RTE.Signal (Storage_Elements.To_Integer (A));
  136.    end Address_To_Signal;
  137.  
  138.    function Address_To_Pointer is new
  139.      Unchecked_Conversion (System.Address, RTE.sigset_t_ptr);
  140.  
  141.    --  local procedures
  142.  
  143.    -----------------------
  144.    -- Handler_Installed --
  145.    -----------------------
  146.  
  147.    function Handler_Installed (S : RTE.Signal) return boolean;
  148.  
  149.    ----------------------
  150.    -- Server_Installed --
  151.    ----------------------
  152.  
  153.    function Server_Installed (S : RTE.Signal) return boolean;
  154.  
  155.    -----------------
  156.    -- Signal_Task --
  157.    -----------------
  158.  
  159.    procedure Signal_Task (T : Tasking.Task_ID; S : RTE.Signal);
  160.  
  161.    -------------------------
  162.    -- Thread_Block_Signal --
  163.    -------------------------
  164.  
  165.    procedure Thread_Block_Signal (S : RTE.Signal);
  166.  
  167.    ---------------------------
  168.    -- Thread_Unblock_Signal --
  169.    ---------------------------
  170.  
  171.    procedure Thread_Unblock_Signal (S : RTE.Signal);
  172.  
  173.    -------------------------
  174.    -- Asynchronous_Signal --
  175.    -------------------------
  176.  
  177.    function Asynchronous_Signal (S : RTE.Signal) return boolean;
  178.  
  179.    -------------------------
  180.    -- Initialize_Blocking --
  181.    -------------------------
  182.  
  183.    procedure Initialize_Blocking;
  184.  
  185.    ------------------------
  186.    -- Unmask_All_Signals --
  187.    ------------------------
  188.  
  189.    procedure Unmask_All_Signals;
  190.  
  191.    ----------------------------
  192.    -- Is_Blocked_Unprotected --
  193.    ----------------------------
  194.  
  195.    function Is_Blocked_Unprotected
  196.      (S : Interfaces.C.POSIX_RTE.Signal) return boolean;
  197.  
  198.    ----------------------------
  199.    -- Is_Ignored_Unprotected --
  200.    ----------------------------
  201.  
  202.    function Is_Ignored_Unprotected
  203.      (S : Interfaces.C.POSIX_RTE.Signal) return boolean;
  204.  
  205.    --  end of local procedure declaratoins.
  206.  
  207.  
  208.    task body Signal_Manager is
  209.       Action : RTE.struct_sigaction;
  210.       Oact : RTE.struct_sigaction;
  211.       Result : Interfaces.C.POSIX_Error.Return_Code;
  212.       Ceiling_Violation : boolean;
  213.    begin
  214.       Unmask_All_Signals;
  215.       --  initially unmask Ref (boundable) signals for which we want
  216.       --  the default action
  217.  
  218.       Initialize_Blocking;
  219.       --  update the Block_Table to reflect the process level blocked signals
  220.  
  221.       loop
  222.          select
  223.          accept Bind_Handler (T : Tasking.Task_ID;
  224.                        E : Tasking.Task_Entry_Index;
  225.                        S : RTE.Signal) do
  226.             if not Asynchronous_Signal (S) then
  227.                raise Program_Error;
  228.             end if;
  229.  
  230.             if Handler_Installed (S) then raise Program_Error; end if;
  231.             --  User should not try to redefine handler before explicitly
  232.             --  detaching it
  233.  
  234.             Write_Lock (M (S), Ceiling_Violation);
  235.  
  236.             User_Handler_Table (S) := Signal_Assoc' (T => T, E => E);
  237.  
  238.             Cond_Signal (C (S));
  239.             --  we have installed a handler if the Handler Task is
  240.             --  waiting to be woke up, do it here.
  241.  
  242.             if not Is_Blocked_Unprotected (S) then
  243.                Thread_Block_Signal (S);
  244.             end if;
  245.             --  This is the case where signal is not blocked and
  246.             --  handler is installed. We want the handler to catch
  247.             --  signal through sigwait. So mask the signal for this
  248.             --  task.
  249.  
  250.             Unlock (M (S));
  251.  
  252.          end Bind_Handler;
  253.  
  254.          or accept Unbind_Handler (T : Tasking.Task_ID) do
  255.  
  256.             for I in Signal_Index loop
  257.                Write_Lock (M (I), Ceiling_Violation);
  258.                if User_Handler_Table (I).T = T then
  259.                   User_Handler_Table (I) := Null_Signal_Assoc;
  260.                   RTE.sigaction (I, Address_To_Pointer (Null_Address),
  261.                                  Action, Result);
  262.                   Assert (Result /= Failure, "GNULL failure---sigaction");
  263.                   --  restore the default action in case sigwait ruined it
  264.  
  265.                   if Is_Ignored_Unprotected (I) then
  266.                      Action.sa_handler :=
  267.                         Storage_Elements.To_Address (RTE.SIG_IGN);
  268.                   else
  269.                      Action.sa_handler :=
  270.                         Storage_Elements.To_Address (RTE.SIG_DFL);
  271.                   end if;
  272.  
  273.                   RTE.sigaction (I, Action, Oact, Result);
  274.                   Assert (Result /= Failure, "GNULL failure---sigaction");
  275.  
  276.                   if not Is_Blocked_Unprotected (I) then
  277.                      --  this is the case where the handler is waiting for
  278.                      --  sigwait. We have to wake this up and make it to
  279.                      --  wait on condition variable. Also.
  280.                      --  unmask the signal to allow the default action again
  281.  
  282.                      Signal_Task (Signal_Server_Table (I).Task_ID, I);
  283.                      Thread_Unblock_Signal (I);
  284.                   end if;
  285.                end if;
  286.                Unlock (M (I));
  287.             end loop;
  288.  
  289.          end Unbind_Handler;
  290.  
  291.          or accept Block_Signal (S : RTE.Signal) do
  292.             --  caller holds mutex M (S)
  293.             Thread_Block_Signal (S);
  294.          end Block_Signal;
  295.  
  296.          or accept Unblock_Signal (S : RTE.Signal) do
  297.             --  caller holds mutex M (S)
  298.             Thread_Unblock_Signal (S);
  299.          end Unblock_Signal;
  300.  
  301.          or terminate;
  302.  
  303.          end select;
  304.  
  305.       end loop;
  306.    end Signal_Manager;
  307.  
  308.    task body Handler_Task is
  309.       Action : RTE.struct_sigaction;
  310.       Sigwait_Mask : RTE.Signal_Set;
  311.       Sigwait_Signal : RTE.Signal;
  312.       Result : Interfaces.C.POSIX_Error.Return_Code;
  313.       Ceiling_Violation : boolean;
  314.    begin
  315.       Tasking.Utilities.Make_Independent;
  316.       --  By making this task independent of master when process goes away
  317.       --  handler will be terminated gracefully.
  318.  
  319.       Write_Lock  (M (S), Ceiling_Violation);
  320.  
  321.       Signal_Server_Table (S).Task_ID := Tasking.Self;
  322.       --  Register the ID of this task so that other can explicitly
  323.       --  send a signal to this task (thread) using pthread_kill
  324.  
  325.       RTE.Signal_Delete_All (Sigwait_Mask);
  326.       RTE.Signal_Add (Sigwait_Mask, S);
  327.  
  328.       loop
  329.          if Is_Blocked_Unprotected (S) or else not Handler_Installed (S) then
  330.             Cond_Wait  (C (S), M (S));
  331.             --  This is the place where we have to take the
  332.             --  default action if the signal is not blocked and there is
  333.             --  no handler installed.
  334.  
  335.             --  wait for Unblock or Bind operation
  336.          else --  wait for actual signal
  337.             Unlock (M (S));
  338.  
  339.             Interfaces.C.Pthreads.sigwait
  340.                (Sigwait_Mask, Sigwait_Signal, Result);
  341.             Assert (Result /= Failure, "GNULLI failure---sigwait");
  342.  
  343.             Write_Lock (M (S), Ceiling_Violation);
  344.             if not Is_Blocked_Unprotected (S) and then
  345.               Handler_Installed (S) and then
  346.               not Is_Ignored_Unprotected (S)
  347.             then
  348.                Unlock (M (S));
  349.                Tasking.Rendezvous.Call_Simple
  350.                  (User_Handler_Table (S).T, User_Handler_Table (S).E,
  351.                   System.Null_Address);
  352.                Write_Lock (M (S), Ceiling_Violation);
  353.             end if;
  354.          end if;
  355.       end loop;
  356.       Unlock (M (S));
  357.    end Handler_Task;
  358.  
  359.    --------------------------
  360.    -- Bind_Signal_To_Entry --
  361.    --------------------------
  362.  
  363.    procedure Bind_Signal_To_Entry (T : Tasking.Task_ID;
  364.                           E : Tasking.Task_Entry_Index;
  365.                           Sig : System.Address) is
  366.       S : RTE.Signal := Address_To_Signal (Sig);
  367.    begin
  368.       Signal_Manager.Bind_Handler (T, E, S);
  369.    end Bind_Signal_To_Entry;
  370.  
  371.    --------------------
  372.    -- Detach_Handler --
  373.    --------------------
  374.  
  375.    procedure Detach_Handler (T : Tasking.Task_ID) is
  376.    begin
  377.       Signal_Manager.Unbind_Handler (T);
  378.    end Detach_Handler;
  379.  
  380.    ------------------
  381.    -- Block_Signal --
  382.    ------------------
  383.  
  384.    procedure Block_Signal (S : RTE.Signal) is
  385.       Ceiling_Violation : boolean;
  386.    begin
  387.       Write_Lock (M (S), Ceiling_Violation);
  388.       if not Is_Blocked_Unprotected (S) then
  389.          Signal_Server_Table (S).Blocked := true;
  390.          if Handler_Installed (S) then
  391.             Signal_Task (Signal_Server_Table (S).Task_ID, S);
  392.          else
  393.             Signal_Manager.Block_Signal (S);
  394.          end if;
  395.       end if;
  396.       Unlock (M (S));
  397.    end Block_Signal;
  398.  
  399.    ---------------------
  400.    -- Unlock_Signal --
  401.    ---------------------
  402.  
  403.    procedure Unblock_Signal (S : RTE.Signal) is
  404.       Ceiling_Violation : boolean;
  405.    begin
  406.       Write_Lock (M (S), Ceiling_Violation);
  407.       if Is_Blocked_Unprotected (S) then
  408.          Signal_Server_Table (S).Blocked := false;
  409.          if Handler_Installed (S) then
  410.             Cond_Signal (C (S));
  411.             --  should make this to wait on sigwait instead cond variable
  412.          else
  413.             Signal_Manager.Unblock_Signal (S);
  414.          end if;
  415.       end if;
  416.       Unlock (M (S));
  417.    end Unblock_Signal;
  418.  
  419.    ----------------
  420.    -- Is_Blocked --
  421.    ----------------
  422.  
  423.    function Is_Blocked (S : Interfaces.C.POSIX_RTE.Signal) return boolean is
  424.       Tmp : boolean;
  425.       Ceiling_Violation : boolean;
  426.    begin
  427.       Write_Lock (M (S), Ceiling_Violation);
  428.       Tmp :=  Signal_Server_Table (S).Blocked;
  429.       Unlock (M (S));
  430.       return Tmp;
  431.    end Is_Blocked;
  432.  
  433.    ----------------
  434.    -- Is_Ignored --
  435.    ----------------
  436.  
  437.    function Is_Ignored (S : Interfaces.C.POSIX_RTE.Signal) return boolean is
  438.       Tmp : boolean;
  439.       Ceiling_Violation : boolean;
  440.    begin
  441.       Write_Lock (M (S), Ceiling_Violation);
  442.       Tmp := Signal_Server_Table (S).Ignored;
  443.       Unlock (M (S));
  444.       return Tmp;
  445.    end Is_Ignored;
  446.  
  447.  
  448.    -------------------
  449.    -- Ignore_Signal --
  450.    -------------------
  451.  
  452.    procedure Ignore_Signal (S : RTE.Signal) is
  453.       Action : RTE.struct_sigaction;
  454.       Oact : RTE.struct_sigaction;
  455.       Result : Interfaces.C.POSIX_Error.Return_Code;
  456.       Ceiling_Violation : boolean;
  457.    begin
  458.       Write_Lock (M (S), Ceiling_Violation);
  459.       if not Is_Ignored_Unprotected (S) then
  460.          RTE.sigaction (S, Address_To_Pointer (Null_Address),
  461.                         Action, Result);
  462.          Action.sa_handler := Storage_Elements.To_Address (RTE.SIG_IGN);
  463.          RTE.sigaction (S, Action, Oact, Result);
  464.          Assert (Result /= Failure, "GNULL failure---sigaction");
  465.          Signal_Server_Table (S).Ignored := true;
  466.       end if;
  467.       Unlock (M (S));
  468.    end Ignore_Signal;
  469.  
  470.    ---------------------
  471.    -- Unignore_Signal --
  472.    ---------------------
  473.  
  474.    procedure Unignore_Signal (S : RTE.Signal) is
  475.       Action : RTE.struct_sigaction;
  476.       Oact : RTE.struct_sigaction;
  477.       Result : Interfaces.C.POSIX_Error.Return_Code;
  478.       Ceiling_Violation : boolean;
  479.    begin
  480.       Write_Lock (M (S), Ceiling_Violation);
  481.       if Is_Ignored_Unprotected (S) then
  482.          RTE.sigaction (S, Address_To_Pointer (Null_Address),
  483.                         Action, Result);
  484.          Action.sa_handler := Storage_Elements.To_Address (RTE.SIG_DFL);
  485.          RTE.sigaction (S, Action, Oact, Result);
  486.          Assert (Result /= Failure, "GNULL failure---sigaction");
  487.          Signal_Server_Table (S).Ignored := false;
  488.       end if;
  489.       Unlock (M (S));
  490.    end Unignore_Signal;
  491.  
  492.    -----------------------
  493.    -- Handler_Installed --
  494.    -----------------------
  495.  
  496.    function Handler_Installed (S : RTE.Signal) return boolean is
  497.    begin
  498.       return User_Handler_Table (S) /= Null_Signal_Assoc;
  499.    end Handler_Installed;
  500.  
  501.    ----------------------
  502.    -- Server_Installed --
  503.    ----------------------
  504.  
  505.    function Server_Installed (S : RTE.Signal) return boolean is
  506.    begin
  507.       return Signal_Server_Table (S).Task_ID /= Tasking.Null_Task;
  508.    end Server_Installed;
  509.  
  510.    -------------------
  511.    --  Signal_Task  --
  512.    -------------------
  513.  
  514.    procedure Signal_Task (T : Tasking.Task_ID; S : RTE.Signal) is
  515.       T_Access : Task_Primitives.TCB_Ptr :=
  516.                    Utilities.ID_To_ATCB (T).LL_TCB'Access;
  517.       Result : Interfaces.C.POSIX_Error.Return_Code;
  518.    begin
  519.       Interfaces.C.Pthreads.pthread_kill
  520.          (T_Access.Thread, S, Result);
  521.       Assert (Result /= Failure, "GNULLI failure---pthread_kill");
  522.    end Signal_Task;
  523.  
  524.    -------------------------
  525.    -- Thread_Block_Signal --
  526.    -------------------------
  527.  
  528.    procedure Thread_Block_Signal (S : RTE.Signal) is
  529.       Signal_Mask, Old_Set : RTE.Signal_Set;
  530.       Result : Interfaces.C.POSIX_Error.Return_Code;
  531.    begin
  532.       RTE.Signal_Delete_All (Signal_Mask);
  533.       RTE.Signal_Add (Signal_Mask, S);
  534.       RTE.sigprocmask (RTE.SIG_BLOCK, Signal_Mask, Old_Set, Result);
  535.       Assert (Result /= Failure, "GNULLI failure---sigprocmask");
  536.    end Thread_Block_Signal;
  537.  
  538.    ---------------------------
  539.    -- Thread_Unblock_Signal --
  540.    ---------------------------
  541.  
  542.    procedure Thread_Unblock_Signal (S : RTE.Signal) is
  543.       Signal_Mask, Old_Set : RTE.Signal_Set;
  544.       Result : Interfaces.C.POSIX_Error.Return_Code;
  545.    begin
  546.       RTE.Signal_Delete_All (Signal_Mask);
  547.       RTE.Signal_Add (Signal_Mask, S);
  548.       RTE.sigprocmask (RTE.SIG_UNBLOCK, Signal_Mask, Old_Set, Result);
  549.       Assert (Result /= Failure, "GNULLI failure---sigprocmask");
  550.    end Thread_Unblock_Signal;
  551.  
  552.    -------------------------
  553.    -- Asynchronous_Signal --
  554.    -------------------------
  555.  
  556.    function Asynchronous_Signal (S : RTE.Signal) return boolean is
  557.    begin
  558.       return Signal_Server_Table (S).Asynchronous;
  559.    end Asynchronous_Signal;
  560.  
  561.    -------------------------
  562.    -- Initialize_Blocking --
  563.    -------------------------
  564.  
  565.    procedure Initialize_Blocking is
  566.       Signal_Mask, Old_Set : RTE.Signal_Set;
  567.       Result : Interfaces.C.POSIX_Error.Return_Code;
  568.    begin
  569.       RTE.sigprocmask (RTE.SIG_BLOCK, Address_To_Pointer (System.Null_Address),
  570.                        Signal_Mask, Result);
  571.       Assert (Result /= Failure, "GNULL failure---sigprocmask");
  572.       for I in Signal_Index loop
  573.          if RTE.Member_Of (Signal_Mask, I) then
  574.             Signal_Server_Table (I).Blocked := true;
  575.          end if;
  576.       end loop;
  577.    end Initialize_Blocking;
  578.  
  579.    ------------------------
  580.    -- Unmask_All_Signals --
  581.    ------------------------
  582.  
  583.    --  Unmask asynchronous signals for calling thread.
  584.  
  585.    procedure Unmask_All_Signals is
  586.       Signal_Mask, Old_Set : RTE.Signal_Set;
  587.       Result : Interfaces.C.POSIX_Error.Return_Code;
  588.    begin
  589.       RTE.Signal_Delete_All (Signal_Mask);
  590.       --  RTE.Signal_Add (Signal_Mask, RTE.SIGABRT);
  591.       RTE.Signal_Add (Signal_Mask, RTE.SIGHUP);
  592.       RTE.Signal_Add (Signal_Mask, RTE.SIGINT);
  593.       RTE.Signal_Add (Signal_Mask, RTE.SIGPIPE);
  594.       RTE.Signal_Add (Signal_Mask, RTE.SIGQUIT);
  595.       RTE.Signal_Add (Signal_Mask, RTE.SIGTERM);
  596.       --  RTE.Signal_Add (Signal_Mask, RTE.SIGUSR1);
  597.       RTE.Signal_Add (Signal_Mask, RTE.SIGUSR2);
  598.       RTE.Signal_Add (Signal_Mask, RTE.SIGCHLD);
  599.       RTE.Signal_Add (Signal_Mask, RTE.SIGCONT);
  600.       RTE.Signal_Add (Signal_Mask, RTE.SIGTSTP);
  601.       RTE.Signal_Add (Signal_Mask, RTE.SIGTTIN);
  602.       RTE.Signal_Add (Signal_Mask, RTE.SIGTTOU);
  603.  
  604.       --  Not POSIX required signals
  605.       RTE.Signal_Add (Signal_Mask, RTE.SIGSYS);
  606.       RTE.Signal_Add (Signal_Mask, RTE.SIGURG);
  607.       RTE.Signal_Add (Signal_Mask, RTE.SIGIO);
  608.       RTE.Signal_Add (Signal_Mask, RTE.SIGXCPU);
  609.       RTE.Signal_Add (Signal_Mask, RTE.SIGXFSZ);
  610.       RTE.Signal_Add (Signal_Mask, RTE.SIGVTALRM);
  611.       RTE.Signal_Add (Signal_Mask, RTE.SIGPROF);
  612.       RTE.Signal_Add (Signal_Mask, RTE.SIGWINCH);
  613.       RTE.Signal_Add (Signal_Mask, RTE.SIGLOST);
  614.  
  615.       RTE.sigprocmask (RTE.SIG_UNBLOCK, Signal_Mask, Old_Set, Result);
  616.       Assert (Result /= Failure, "GNULL failure---sigprocmask");
  617.    end Unmask_All_Signals;
  618.  
  619.    ----------------------------
  620.    -- Is_Blocked_Unprotected --
  621.    ----------------------------
  622.  
  623.    function Is_Blocked_Unprotected
  624.      (S : Interfaces.C.POSIX_RTE.Signal) return boolean is
  625.    begin
  626.       return Signal_Server_Table (S).Blocked;
  627.    end Is_Blocked_Unprotected;
  628.  
  629.    ----------------------------
  630.    -- Is_Ignored_Unprotected --
  631.    ----------------------------
  632.  
  633.    function Is_Ignored_Unprotected
  634.      (S : Interfaces.C.POSIX_RTE.Signal) return boolean is
  635.    begin
  636.       return Signal_Server_Table (S).Ignored;
  637.    end Is_Ignored_Unprotected;
  638.  
  639. end System.Signals;
  640.